package com.wg.msuser.serviceImp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.wg.msuser.entity.UserAddress;
import com.wg.msuser.mapper.UserAddressMapper;
import com.wg.msuser.service.IUserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserAddressServiceIml extends ServiceImpl<UserAddressMapper, UserAddress> implements IUserAddressService {
    @Autowired
    private UserAddressMapper userAddressMapper;
    @Override
    public List<UserAddress> listByUserId(Integer userId) {
        return this.list(new QueryWrapper<UserAddress>().eq("user_id", userId));
    }
    @Override
    public boolean setAllNonDefaultByUserId(Integer userId) {
        return userAddressMapper.updateAllNonDefaultByUserId(userId) >= 0;
    }

    @Override
    public int SetDefault(Integer id) {
        return userAddressMapper.SetDefault(id);
    }
}
